import pymysql


# 封装数据库配置
def get_connect():
    connect = pymysql.connect(
        host="litemall.hogwarts.ceshiren.com",
        port=13306,
        user="test",
        password="test123456",
        database="litemall",
        charset="utf8mb4"
    )
    return connect

# 执行sql语句
def execute_mysql(sql):
    connect = get_connect()
    curses = connect.cursor()
    curses.execute(sql)
    # 获取一条数据
    record = curses.fetchone()
    return record

if __name__ == '__main__':
    print(execute_mysql("select * from litemall_cart where "
            "user_id=1 and deleted=0 and "
            "goods_name='hogwartss7'"))
